package cn.com.enersun.iec61850.web.mapper;

import cn.com.enersun.iec61850.web.domain.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

/**
 * Created by lionel on 2017/4/19.
 */
@Mapper
public interface UserMapper {
    @Select("select * from user where name = #{name}")
    User findByName(@Param("name") String name);

    @Insert("INSERT INTO USER(id, NAME, AGE) VALUES(#{id}, #{name}, #{age})")
    @SelectKey(statement = "select replace(uuid(),'-','')", keyProperty = "id", resultType = String.class, before = true)
    int insert(User user);

    @Update("UPDATE user SET age=#{age} WHERE name=#{name}")
    void update(User user);

    @Delete("DELETE FROM user WHERE id =#{id}")
    void delete(String id);
}
